package tt.dz.appserver.dao.ext;

import org.apache.commons.collections.map.ListOrderedMap;
import org.springframework.stereotype.Repository;

import tt.dz.appserver.dao.base.BasisDao;
import tt.dz.appserver.entity.model.AppFeedBack;

import java.util.List;
import java.util.Map;

@Repository
public class AppFeedBackDao extends BasisDao<AppFeedBack>{
	
	/**查询用户反馈*/
	private static final String FIND_APP_FEEDBACK_BY_USER = 
			"SELECT user_id, create_time, user_phone, content, dispose_flag, "
			+ "update_time, oper_id FROM as_app_feedback "
			+ "WHERE user_id = ? AND valid_flag = 1 "
			+ "ORDER BY create_time DESC;";
	
	public List<Map<String,Object>> findAppFeedbackByUser(String userid) {
		
		List<Map<String,Object>> maps = super.findDataOfMapBySQL(new StringBuffer(FIND_APP_FEEDBACK_BY_USER), null, null, userid, 1);
		
		return maps;
		
	}
	
	/**逻辑删除用户反馈*/
	public int delAppFeedback(AppFeedBack appFeedback) {
		
		return super.update(appFeedback);
	
	}
	
	
	/**修改用户反馈*/
	public int UpdateAppFeedbac(AppFeedBack appFeedback) {
		
		return super.update(appFeedback);
		
	}
	
	
	/**查询有效用户反馈*/
	public List<AppFeedBack> findAppFeedbackValid() {
		Integer validflag = 1;
		ListOrderedMap map = new ListOrderedMap();
		map.put("valid_flag", validflag);
		
		List<AppFeedBack> appFeedbackList = super.findListAutomaticOfClass(AppFeedBack.class, map, 
				null, null, "create_time", 2);
		
		return appFeedbackList;
	}

}
